<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>合同生成记录</title>
	<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
	<div class="searchArea">
		<form id="searchBar">
			<div class="fieldset1 clearFix">
				<div class="FXBR">
					<div class="fieldBox">
						<div class="label">批号</div>
						<div class="field">
							<input name="batchNumber" id="batchNumber" type="text" class="ui-textbox" value="" ligerui="width: 160">
						</div>
					</div>
				</div>

				<div class="clearFix"></div>
				<div class="btnsBox formBtns notRight">
					<span id="searchBtn" onclick="searchBtn();" class="sq-button-round">查询</span>
					<span id="clearBtn" onclick="clearBtn();" class="sq-button-round">清空</span>
					<input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
				</div>
			</div>
		</form>
	</div>
</div>
<div id="logGrid" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null;
    $(function () {
        initForm();
        initGrid();//注意初始化要在initForm之后,因为在初始化grid的时候需要form参数
    });


    //初始化表单
    function initForm(){
        $("#searchBar").ligerForm();
    }

    //查询按钮事件
    function searchBtn(){
        var form = new liger.get("searchBar");
        var data = form.getData();
        for (batchNumber in data){
            grid.setParm(batchNumber,data[batchNumber]);
        };
        grid.reload();
    }

    //查询参数
    function getSearchParams(){
        var form = new liger.get("searchBar");
        var data = form.getData();
        return data;
    }

    //初始化列表
    function initGrid(){
        $("#logGrid").ligerGrid({
            url: '<%=path%>/project/prjContCreatRec/initList.do',
            method : 'post',
            isSingleCheck: true,

            parms:getSearchParams(),
            columns: [
                { display: '批次', name: 'batchNo', width: 150},
                { display: '合同号', name: 'lsCntNo', minWidth: 140 },
                { display: '提示信息', name: 'desc', minWidth: 140,render: errorInfoRender },
                { display: '客户', name: 'cstNm', minWidth: 60,align:'center', enabledSort:true},
                { display: '客户经理', name: 'cstMgrNm', minWidth: 60,align:'center', enabledSort:true},

                { display: '项目名称', name: 'prjNm', minWidth: 60 , enabledSort:true},
                { display: '项目配置', name: 'cfgCd', minWidth: 60 , enabledSort:true },
                { display: '是否强签', name: 'forceSign', minWidth: 60 , enabledSort:true,    render: function (item)
                    {
                        if (parseInt(item.forceSign) == 1) {return '是';}else{
                            return '否';
                        }

                    }
                },
                { display: '创建时间', name: 'crtTm', width: 150, render:renderDate, enabledSort:true }

            ],
            pageSize:10,
            root:'rows',
            record:'total',
            hideLoadButton : true,
            width: '100%',
            height:'100%',
            heightDiff:-2,
            //checkbox:true,
            rownumbers:true
        });
        grid = liger.get("logGrid");
        grid.setHeight(100);
    }

    function errorInfoRender(rowdata, index, value) {
        var dataState =  rowdata.isValid;
        var cfgCd = rowdata.cfgCd;
        if(dataState == 1){
            if(cfgCd==''||cfgCd==null){
                return "<span class='project-span project-span-dangeer'>请先选择合同配置</span>";
            }else {
                return "<span class='project-span project-span-success'>" + value + "</span>";
            }
        }else{

            return "<span class='project-span project-span-dangeer'>"+value+"</span>";

        }
    }


    //格式化时间
    function renderDate(rowdata, index, value){
        var dateStr = "";
        if(null != value){
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }

    //清空按钮事件
    function clearBtn(){
        $("#resetBtn").click();  //重置 input-text
        var form = new liger.get("searchBar");
        form.setData({  //重置select等特殊表单
            "name":""
        });
    }

    function iframeResize () {
        if (parent.mainApp) {
            parent.mainApp.parentTab.onResize();
        };
    }
</script>

</body>
</html>